package edu.cuit.jead.mynetdisk.common;

import lombok.AllArgsConstructor;
import lombok.Data;
//统一返回类
@Data
@AllArgsConstructor
public class Result<T> {

    private Integer Code;
    private String msg;
    private T data;

    private Result(int code, String msg, T data) {
        this.Code = code;
        this.msg = msg;
        this.data = data;
    }
    public static <T> Result success(T data) {
        Result result = new Result(200,"success",data);
        return result;
    }
    public static <T> Result success(String msg, T data) {
        Result result = new Result(200,msg,data);
        return result;
    }
    public static <T> Result error(Code code) {
        Result result = new Result(code.getCode(),code.getMsg(),null);
        return result;
    }
    public static <T> Result error(int code, String msg) {
        Result result = new Result(code,msg,null);
        return result;
    }
}
